using System;
using System.Globalization;
using System.Reflection;
using System.Reflection.Emit;
using RaisingStudio.SmallBasicCompiler.Expressions;

namespace RaisingStudio.SmallBasicCompiler.Statements
{
	public class MethodCallStatement : Statement
	{
		public MethodCallExpression MethodCallExpression;
		public override void AddSymbols(SymbolTable symbolTable)
		{
			if (this.MethodCallExpression != null)
			{
				this.MethodCallExpression.AddSymbols(symbolTable);
			}
		}
		public override void EmitIL(CodeGenScope scope)
		{
			this.MethodCallExpression.EmitIL(scope);
			MethodInfo methodInfo = this.MethodCallExpression.GetMethodInfo(scope);
			if (methodInfo.ReturnType != typeof(void))
			{
				scope.ILGenerator.Emit(OpCodes.Pop);
			}
		}
		public override string ToString()
		{
			return string.Format(CultureInfo.CurrentUICulture, "{0}\r\n", new object[]
			{
				this.MethodCallExpression
			});
		}
	}
}
